<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台登录-X-admin2.0</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link rel="stylesheet" href="xadmin/css/font.css">
	<link rel="stylesheet" href="xadmin/css/xadmin.css">
	
	<script src="assets/jquery/jquery-1.9.1.min.js"></script>
    <script src="xadmin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="xadmin/js/xadmin.js"></script>
    

</head>
<body class="login-bg">
    
    <div class="login layui-anim layui-anim-upbit">
        <div class="message">x-admin2.0-管理登录</div>
        <div id="darkbannerwrap"></div>
        
        <form method="post" class="layui-form" >
            <input name="username" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
            <hr class="hr15">
            <input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20" >
        </form>
    </div>

    <script>
    	var basePath=getPath();
        $(function  () {
            layui.use('form', function(){
              var form = layui.form;
              //监听提交
              form.on('submit(login)', function(data){
                
            	  login(data.field);
				
              });
            });
        });
        
        function login(data){
        	console.log(data);
        	console.log(basePath);
        	jQuery.ajax({
        		url:"http://localhost:8090/system/login",
        		type:"post",
        		data:data,
        		success:function(result){
        			console.log(result);
        			window.location.href="index.html";
        		},
        		error:function(){
        			layer.msg("请求失败");
        		}
        	});
        }
        
     	//访问路径
		function getPath(){
			var pathName = window.location.href;   
		    var index = pathName.lastIndexOf("/");   
		    var result = pathName.substr(0,index+1);  
		    return result;
		}
        
    </script>

</body>
</html>